import { Result, ResultError } from "@/types";
import { Ref, ref, reactive, watch, getCurrentInstance } from "vue";
import { cancelOrderRefund } from "@/api/order-refund";
export default function (_call: any) {

    const { proxy } = getCurrentInstance() as any;
    const {
        proxy: { $utils },
    } = getCurrentInstance() as any;

    const _toDetail = (id: number) => {
        $utils.routeRedirectTo("/otherpages/user/order_refund/detail", { id })
    }

    // 取消
    const _toCancel = (id: number) => {
        uni.showModal({
            title: "友情提示",
            content: "确认要取消该订单吗？",
            success(o) {
                if (o.confirm) {
                    cancelOrderRefund({
                        id
                    }).then((res: Result) => {
                        $utils.successMsg(res.message)
                        if (typeof _call == 'function') {
                            _call()
                        }
                    }).catch((err: ResultError) => {
                        $utils.errorMsg(err)
                    })
                }
            }
        })
    }
    return {
        _toDetail,
        _toCancel
    }
}